Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
How does -5 >> 2 === -2?

In the MDN docs, there is this example below under right shift operator.

const a = 5;          //  00000000000000000000000000000101
const b = 2;          //  00000000000000000000000000000010
const c = -5;         // -00000000000000000000000000000101

console.log(a >> b);  //  00000000000000000000000000000001
// expected output: 1

console.log(c >> b);  // -00000000000000000000000000000010
// expected output: -2

5 >> 2 makes sense because you shift the digits right 2 spaces. In the second example of -5 >> 2, why does it only seemingly shift to the right one space even though it's >> 2?

MDN Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Right_shift

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just like Johnny side, you might want to check the Two's complement rule. The number in left most might be 1 inside of 0. You might want to check the example with -9 this example will help you understand better.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda